# -*- coding: utf-8 -*-
import xlrd


class ExcelTool(object):
    @staticmethod
    def get_one_row(file_path, sheet_page, row):
        excel_file = xlrd.open_workbook(file_path)
        sheet = excel_file.sheet_by_index(sheet_page)
        return sheet.row_values(row)

    @staticmethod
    def get_one_col(file_path, sheet_page, row):
        excel_file = xlrd.open_workbook(file_path)
        sheet = excel_file.sheet_by_index(sheet_page)
        return sheet.col_values(row)

    @staticmethod
    def get_all_row(file_path, sheet_page):
        excel_file = xlrd.open_workbook(file_path)
        sheet = excel_file.sheet_by_index(sheet_page)
        res = []
        for x in range(sheet.nrows):
            # print(sheet.row_values(x))
            res.append(sheet.row_values(x))

        return res


if __name__ == '__main__':
    file = r'D:\commercial_opportunity_zhu\testfile\test.xls'
    a = ExcelTool.get_one_row(file, 1, 0)
    b = ExcelTool.get_one_col(file, 1, 0)
    c = ExcelTool.get_all_row(file, 1)
    print(a)
    print(b)
    print(c)
